//
//  SISSNetworkingManager+Complain.m
//  SISSAPP
//
//  Created by 袁应荣 on 2018/12/24.
//  Copyright © 2018 优房网. All rights reserved.
//

#import "SISSNetworkingManager+Complain.h"
#import "SISSNetworkingManager+File.h"

@implementation SISSNetworkingManager (Complain)

// 6.13.1  添加投诉建议记录  //图文上传
- (void)insertComplainAndSuggestionWithAcrId:(NSString *)acrId complainType:(NSInteger)complainType commentType:(NSInteger)commentType content:(NSString *)content images:(NSArray<UIImage *> *)images success:(void (^)(id))successBlock failed:(void (^)(NSError *))failedBlock {
    [SISSPublicSingleton shared].isHud = NO;
    if (images && images.count > 0) {
        [kNetworkNoUTF8Manager commonUploadFilesWithImages:images success:^(id  _Nonnull responseObject) {
            NSLog(@"%@",responseObject);
            if ([responseObject[@"code"] integerValue] == 200) {
                NSArray *dataArr = responseObject[@"data"];
                NSDictionary *parameters = @{
                                             @"saId":[SISSUserAccount shared].saId,
                                             @"content":content,
                                             @"acrId":acrId,
                                             @"complainType":@(complainType),
                                             @"commentType":@(commentType),
                                             @"file":dataArr
                                             };
                [kNetworkNoUTF8Manager POSTWithURLString:URL_INSERT_COMPLAIN_SUGGESTION parameters:parameters success:^(id responseObject) {
                    NSLog(@"6.13.1  添加投诉建议记录 (图文上传): responseObject-->%@",responseObject);
                    
                    if (successBlock) {
                        successBlock(responseObject);
                    }
                } failure:^(NSError *error) {
                    if (failedBlock) {
                        failedBlock(error);
                    }
                }];
            }
        } failed:^(NSError * _Nonnull error) {
            NSLog(@"%@",error);
        }];
    } else {
        NSDictionary *parameters = @{
                                     @"saId":[SISSUserAccount shared].saId,
                                     @"content":content,
                                     @"acrId":acrId,
                                     @"complainType":@(complainType),
                                     @"commentType":@(commentType)
                                     };
        [kNetworkNoUTF8Manager POSTWithURLString:URL_INSERT_COMPLAIN_SUGGESTION parameters:parameters success:^(id responseObject) {
            NSLog(@"6.13.1  添加投诉建议记录: responseObject-->%@",responseObject);
            
            if (successBlock) {
                successBlock(responseObject);
            }
        } failure:^(NSError *error) {
            if (failedBlock) {
                failedBlock(error);
            }
        }];
    }
    
}

@end
